package structure.adapte.springmvc;

/**
 * @author dali
 * @date 2021-07-12 21:20
 * @Description 每个handler的适配器
 */

public interface HandlerAdapter {
    boolean supports(Object handler);
    void handler(Object handler);
}

class HttpHandlerAdapter implements HandlerAdapter {

    @Override
    public boolean supports(Object handler) {
        return handler instanceof HttpHandel;
    }

    @Override
    public void handler(Object handler) {
        ((HttpHandel)handler).doHttpHandel();
    }
}

class SimpleHandlerAdapter implements HandlerAdapter {

    @Override
    public boolean supports(Object handler) {
        return handler instanceof SimpleHandel;
    }

    @Override
    public void handler(Object handler) {
        ((SimpleHandel)handler).doSimpleHandel();
    }
}